<template>
	<view>
		<view class="title">
			<view :class="{active:show==1}" @click="show=1">
				精选文章
			</view>
			<view :class="{active:show==2}" @click="show=2">
				好物推荐
			</view>
		</view>
		<view class="center">
			<view class="center-title">
				<view :class="{now:currentKind==item.id}" v-for="item in kindlist" :key="item.id" @click="cut(item.id)">
					<image :src="item.icons" mode=""></image>
				</view>

			</view>

		</view>

		<view class="find-center" v-for="item in aritlceList" :key="item.id">
			<view class="top">
				<image :src="item.coverImg" mode=""></image>
				<view class="text">
					<text class="bigtext"> {{item.title}}</text><br>
					<text>{{item.author}}</text>
				</view>
			</view>
			<view class="under">
				<image src="../../static/icons/view.png" mode=""></image>
				<image @click="zan" src="../../static/icons/zan.png" mode=""></image>
			</view>
		</view>


	</view>
</template>

<script>
	import FindIndex from '@/api/find/index.js'
	export default {
		name: 'find',
		data() {
			return {
				show: '1',
				ishow: '1',
				kindlist: [],
				currentKind: '',
				aritlceList: []
			};
		},
		methods: {
			getkindlist() {
				FindIndex.kindlist().then((res) => {
					var icons = [
						'../../static/icons/chuangyi.png',
						'../../static/icons/shipin.png',
						'../../static/icons/fengge.png',
						'../../static/icons/dengju.png'
					]
					for (var i = 0; i < res.data.data.length; i++) {
						res.data.data[i].icons = icons[i]
					}
					this.kindlist = res.data.data

					this.currentKind = res.data.data[0].id;
					this.getseriesAll()

				})
			},
			getseriesAll() {
				FindIndex.aritlceList({
					kindId: this.currentKind
				}).then((res) => {
			
					this.aritlceList = res.data.data.list
				})
			},
			zan() {
				uni.showToast({
					title: '已点赞',
					duration: 2000
				});
			},
			cut(id){
				this.currentKind=id
				FindIndex.aritlceList({
					kindId: this.currentKind
				}).then((res) => {
					this.aritlceList = res.data.data.list
				})
			}

		},
		onLoad() {
			this.getkindlist()


		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f1ece7;
	}

	.title {
		width: 100%;
		height: 230rpx;
		background: #354e44;
		display: flex;
		justify-content: center;

		color: #fff;

		view {
			height: 60rpx;
			margin: 0 20rpx;
			margin-top: 100rpx;
		}

		.active {
			margin: 0 20rpx;
			margin-top: 100rpx;

			border-bottom: 2px solid #fff;
		}
	}

	.center {
		border-radius: 40rpx 40rpx 0 0;
		overflow: hidden;
		background: #f1ece7;
		margin-top: -40rpx;

		.center-title {
			height: 150rpx;
			width: 100%;
			display: flex;
			margin-top: 50rpx;
			justify-content: space-around;

			view {
				width: 84rpx;
				height: 84rpx;
				border-radius: 50%;
				background: #fff;
              

				image {
					margin-top: 15rpx;
					margin-left: 15rpx;
					width: 60rpx;
					height: 60rpx;
				}
			}

			.now {
				width: 98rpx;
				height: 98rpx;
				border-radius: 50%;
				background: #354e44;

				image {
					margin-top: 20rpx;
					margin-left: 20rpx;
					width: 60rpx;
					height: 60rpx;
				}
			}
		}
	}

	.find-center {
		border-radius: 50rpx;
		width: 674rpx;
		height: 482rpx;
		margin: 0 auto;
		margin-bottom: 40rpx;


		.top {
			width: 100%;
			height: 382rpx;
			background: red;
			position: relative;

			image {
				width: 100%;
				height: 100%;
			}

			.text {
				margin-left: 20rpx;
				position: absolute;
				top: 260rpx;
				color: #fff;

			}
		}

		.under {
			width: 100%;
			height: 100rpx;
			background: #fff;
			display: flex;
			justify-content: space-between;

			image {
				margin: 30rpx 40rpx;
				width: 60rpx;
				height: 43rpx;
			}
		}
	}
</style>
